package day1106.CompanySet;

import java.util.*;

//1:公司有公司名称，注册地址，电话，经营范围等属性

public class Company  {
    String name = "aaa";
    String address = "bbb";
    String phonenum = "ccc";
    String industry = "ddd";
    int pos = 0;
    Set<Staff> set = new HashSet<>();
    @Override
    public String toString() {
        return "Company{" +
                "公司名为：'" + name + '\'' +
                ", 公司地址为：'" + address + '\'' +
                ",联系电话为：'" + phonenum + '\'' +
                ",经营范围为：'" + industry + '\'' +
                '}';
    }
    //公司有招聘员工（要求工号不能重复），有输出员工信息，以及辞退员工，和统计公司人数,获得公司薪水最高的员工的方法
    //添加员工
    public void add(String name, int age, String sex, String post, double salary, String num){
        for (Staff staff:set){
            if (staff.getNum().equals(num)){
                System.out.println("工号重复，添加失败");
                return;
            }
        }
        set.add(new Staff(name,age,sex,post,salary,num));
        System.out.println("添加成功");
        pos++;
    }
    //公司人数
    public void num(){
        System.out.println(pos);
    }

    //查询
    public void show(){
        for (Staff staff:set){
            System.out.println(staff);
        }
    }
    //辞退员工
    public void delete(String num){
        for (Staff staff:set){
            if (staff.getNum().equals(num)){
                set.remove(staff);
                System.out.println("删除成功");
                return;
            }
        }
        System.out.println("删除失败，工号输入错误");
        return;

    }
    //薪水最高的
    public void max(){
        Iterator<Staff> iterator = set.iterator();
        Staff staff = iterator.next();
        while (iterator.hasNext()){
            if (staff.getSalary()<=iterator.next().getSalary());
            staff=iterator.next();
        }
        System.out.println(staff);

    }
    //涨薪水


}
